home *** CD-ROM | disk | FTP | other *** search
- ; Distortion engine, v2.0
- ; by Maple Leaf, Nov 1996
- ; A crappy piece of unoptimized assembler...
- ; Do whatever you want with it... It isn't much useful, anyway :)))
- ;-**************************************************************************-
-
- .model TPascal
- .386
-
- .DATA
-
- extrn Img:DWORD
-
- extrn temp:WORD
- extrn vScr:WORD
-
- extrn Wave1:WORD
- extrn Wave2:WORD
- extrn Wave3:WORD
- extrn Wave4:WORD
-
- extrn SinTab:WORD
- extrn CosTab:WORD
-
- extrn MaxAmplV:WORD ; the real amplitude = MaxAmpl * 2 !!!!
- extrn MaxAmplH:WORD ; the real amplitude = MaxAmpl * 2 !!!!
- extrn AngleIncrement:WORD ; only bits 0-7 are used
-
-
-
-
- .CODE
-
- public UpdateWaves
- public HoriDistort
- public VertDistort
-
- include jumps.inc
-
- ;-- some useful macros ------------------------------------------------------
-
- LoadSin macro factor
- mov di,bx
- shl di,factor
- and di,0FFh ; is it correct ?
- add di,di
- mov cx,SinTab[di]
- endm
-
- LoadCos macro factor
- mov di,bx
- shl di,factor
- and di,0FFh ; is it correct ?
- add di,di
- mov cx,CosTab[di]
- endm
-
- Normalize macro
- shrd ax,dx,8
- sar dx,8 ; quite irrelevant
- endm
-
- uWaveH macro ofs
- add si,si
- add ax,MaxAmplH
- mov [si+ofs],ax
- shr si,1
- endm
-
- uWaveV macro ofs
- add si,si
- add ax,MaxAmplV
- mov [si+ofs],ax
- shr si,1
- endm
-
- ;--- don't laugh too loud of what follows :) --------------------------------
-
- ang dw 0
-
- proc UpdateWaves near
-
- mov ax,AngleIncrement
- add cs:ang,ax
- and cs:ang,0FFh
-
- mov cx,200
- mov si,0 ; k
-
- @L1: push cx
- mov bx,si
- add bx,cs:ang ; (k+ang)
-
- ; *** Wave1[] ***
- mov ax,MaxAmplH
- LoadSin 1 ; cx:=sin((k+ang) shl 1)
- imul cx
- Normalize
- LoadCos 3 ; cx:=cos((k+ang) shl 3)
- imul cx
- Normalize
- uWaveH Wave1
-
- ; *** Wave2[] ***
- mov ax,MaxAmplH
- LoadCos 3 ; cx:=cos((k+ang) shl 3)
- imul cx
- Normalize
- LoadSin 2 ; cx:=sin((k+ang) shl 2)
- imul cx
- Normalize
- uWaveH Wave2
-
- inc si
- pop cx
- dec cx
- jnz @L1
-
- mov cx,320
- mov si,0 ; k
-
- @L2: push cx
- mov bx,si
- add bx,cs:ang ; (k+ang)
-
- ; *** Wave3[] ***
- mov ax,MaxAmplV
- LoadSin 3 ; cx:=sin((k+ang) shl 3)
- imul cx
- Normalize
- LoadSin 1 ; cx:=sin((k+ang) shl 1)
- imul cx
- Normalize
- uWaveV Wave3
-
- ; *** Wave4[] ***
- mov ax,MaxAmplV
- LoadCos 0 ; cx:=cos((k+ang) shl 1)
- imul cx
- Normalize
- LoadCos 3 ; cx:=cos((k+ang) shl 3)
- imul cx
- Normalize
- uWaveV Wave4
-
- inc si
- pop cx
- dec cx
- jnz @L2
-
- retn
- endp UpdateWaves
-
- ;--- horizontal distortion routine -----------------------------------------
-
- fillGap macro count
- mov cx,count
- mov al,0
- rep stosb
- endm
-
- counter1 dw 0
-
- proc HoriDistort near
-
- push ds es fs
- mov di,0 ; Temp offset
- mov si,0 ; Img offset
-
- mov cx,200
-
- push ds
- pop fs
- mov es,Temp
- mov ds,Img[2]
-
- mov bx,0 ; line no. (k)
-
- @HDL: push bx cx
- mov si,bx
- add bx,bx
-
- assume fs:DATA
- fillGap fs:Wave1[bx] ; LEFT black area size
-
- mov ecx,319
- sub cx,fs:Wave2[bx]
- sub cx,fs:Wave1[bx]
- inc cx ; cx = NewXSize
- mov eax,1400000h ; 320 * 65536
- xor edx,edx
- div ecx
- mov word ptr cs:smc1+5,ax
- shr eax,16
- mov word ptr cs:smc2+2,ax
-
- mov cs:counter1,0
- mov dx,si
- shl si,6
- shl dx,8
- add si,dx ; k*320
-
- @@L3: mov al,[si]
- stosb
- smc1: add cs:counter1,1234h
- smc2: adc si,1234h
- dec cx
- sjnz @@L3
-
- fillGap fs:Wave2[bx] ; RIGHT black area size
-
- pop cx bx
- inc bx
- dec cx
- sjnz @HDL
-
- pop fs es ds
-
- retn
- endp HoriDistort
-
- ;--- vertical distortion routine --------------------------------------------
-
- StoreByte macro
- mov es:[di],al
- add di,320
- endm
-
- fillGap2 macro count
- local @LA1, @SLA1
- mov cx,count
- sjcxz @@SLA1
- mov al,0
- @@LA1: StoreByte
- dec cx
- sjnz @@LA1 ; draw it
- @@SLA1: endm
-
- fillGap3 macro count
- local @LA2, @SLA2
- mov cx,count
- sjcxz @@SLA2
- mov al,0
- @@LA2: StoreByte
- dec cx
- sjnz @@LA2 ; draw it
- @@SLA2:
- endm
-
- proc VertDistort near
-
- push ds es fs
- mov di,0 ; vScr offset
- mov si,0 ; Temp offset
-
- mov cx,320
-
- push ds
- pop fs
- mov es,vScr
- mov ds,Temp
-
- mov bx,0 ; col no. (k)
-
- @VDL: push bx cx
- mov di,bx
- mov si,bx
- add bx,bx
-
- assume fs:DATA
- fillGap2 fs:Wave3[bx] ; TOP black area size
-
- mov ecx,199
- sub cx,fs:Wave4[bx]
- sub cx,fs:Wave3[bx]
- inc cx ; cx = NewYSize
- mov eax,0C80000h ; (200 * 65536)
- xor edx,edx
- div ecx ; eax=(200/NewYsize) * 65536
-
- mov word ptr cs:smc3+5,ax ;
- shr eax,16 ; SMCODE init
- mov word ptr cs:smc4+2,ax ;
-
- mov cs:counter1,0
- mov dx,0
-
- push bx
- mov word ptr cs:smc5+2,si
-
- @@C4: mov al,[si]
- StoreByte
- smc3: add cs:counter1,1234h
- smc4: adc dx,1234h
-
- mov bx,dx ; ughhh, shit ! these take a lot of useful
- mov si,bx ; time !
- shl bx,6 ; is there any other choice ?
- shl si,8 ;
- add si,bx ;
- smc5: add si,1234h ;
-
- dec cx
- sjnz @@C4
- pop bx
-
- fillGap3 fs:Wave4[bx] ; BOTTOM black area size
-
- pop cx bx
- inc bx
- dec cx
- jnz @VDL
-
- pop fs es ds
-
- retn
- endp VertDistort
-
- END
-
- ; hhrrrrrr...